#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/1/26 17:27
# @Author  : Ramsey
# @Site    : zh
# @File    : priority_queue.py
# @Software: PyCharm
import asyncio
from asyncio import PriorityQueue, TimeoutError


class SpiderPriorityQueue(PriorityQueue):
    def __init__(self, maxsize: int = 0):
        super().__init__(maxsize=maxsize)

    async def get(self):
        core = super().get()
        try:
            request = await asyncio.wait_for(core, timeout=0.1)
        except TimeoutError:
            return None
        else:
            return request


if __name__ == "__main__":
    pass
